
import http from "wechat-http"


// 配置请求头
http.baseURL = 'http://124.223.14.236:8060/home'

// 配置请求拦截器
http.intercept.request = (config)=>{
  const token = wx.getStorageSync('token')
  config.header = {
    ...config.header,
    'Token': token
  };
  return config
}
//配置响应拦截器
http.intercept.response = (response)=>{
  if(response.data.errno === 9997){
    console.log(22);
    // 清空token
    getApp().removeToken('token')
    wx.utils.toast('token失效，请重新登录！')
    // 跳转页面
    wx.redirectTo({
      url: '/pkgUser/pages/login/login',
    })
  }
  return response.data
} 

export default http
wx.http = http